package com.example.tests;

import com.example.utils.ListOf;
import org.testng.annotations.Test;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

public class TestFolderRemoving extends TestBase {

    @Test
    public void testRemoveOneFolder() throws Exception {
        // test data
        int folderIndex = 0;

        // save old state
        ListOf<FolderData> oldList = app.getFoldersHelper().getFolders();

        // add one folder to prevent situation with zero folders
        FolderData folderData = new FolderData().withName("New Folder 4");
        app.getFoldersHelper().createFolder(folderData);

        // save new state
        ListOf<FolderData> newList = app.getFoldersHelper().getFolders();

        // check folder added correctly
        oldList.add(folderData);
        assertThat(newList, equalTo(oldList));

        // remove first folder
        app.getFoldersHelper().removeFolder(folderIndex);

        // save new state
        newList = app.getFoldersHelper().getFolders();

        // check folder removed correctly
        oldList.remove(folderIndex);
        assertThat(newList, equalTo(oldList));
    }
}
